package com.xh.bussiness.permission.service.impl;

import com.xh.bussiness.permission.bean.request.UserLoginLogRequest;
import com.xh.bussiness.permission.model.UserLoginLog;
import com.xh.bussiness.permission.dao.UserLoginLogMapper;
import com.xh.bussiness.permission.service.IUserLoginLogService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.core.bean.XhPage;
import com.xh.core.util.StringUtils;
import java.util.List;
/**
 * <p>
 * 用户登录日志表 服务实现类
 * </p>
 *
 * @author Jqm
 * @since 2021-02-19
 */
@Service
public class UserLoginLogServiceImpl extends BaseServiceImpl<UserLoginLogMapper, UserLoginLog> implements IUserLoginLogService {
    @Override
    public XhPage queryUserLoginLogPage(XhPage page, UserLoginLogRequest bean) {
        QueryWrapper qw=new QueryWrapper<UserLoginLog>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public List queryUserLoginLog(UserLoginLogRequest bean) {
        QueryWrapper qw=new QueryWrapper<UserLoginLog>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }


    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(UserLoginLogRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        return qw;
    }
}
